using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;

namespace ImprCheques
{
    public partial class frmVisor2 : Form
    {
        //private const string CURRENT_PRINTER = @"\\sanjose15\LexmarkF";
        public Cheques informe = new Cheques();

        public frmVisor2(DataTable dt)
        {
            InitializeComponent();
            informe.SetDataSource(dt);
            crystalReportViewer1.ReportSource = informe;
        }

        private void btnImprimir_Click(object sender, EventArgs e)
        {
            PrintDocument printDoc = new PrintDocument();
            //printDoc.PrinterSettings.PrinterName = CURRENT_PRINTER;
            PaperSize PkSize = new PaperSize();

            for (int i = 0; i <= printDoc.PrinterSettings.PaperSizes.Count - 1; i++)
            {
                if (printDoc.PrinterSettings.PaperSizes[i].PaperName.ToString() == "Cheques")
                {
                    PkSize = printDoc.PrinterSettings.PaperSizes[i];
                }
            }
            //informe.PrintOptions.PrinterName = CURRENT_PRINTER;
            informe.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)PkSize.RawKind;
            informe.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;
            informe.PrintToPrinter(1, true, 1, 99);
            MessageBox.Show("Los cheques se enviaron a la impresora." ,"Impresion de Cheques",MessageBoxButtons.OK,MessageBoxIcon.Information);
            this.Close();
        }
    }
}